
let SWDA_Help = {};
SWDA_Help.Window_Help_initialize = Window_Help.prototype.initialize;
Window_Help.prototype.initialize = function(numLines) {
    SWDA_Help.Window_Help_initialize.call(this,numLines);
    this.setBackgroundType(1)//dimmer type
    this.setNormalColor('#fff');
    this.changeTextColor(this.normalColor())
    this._ext = '';
    //this.setSmallerFont();
};



// 添加右下角“详细说明”文字提示
SWDA_Help.Window_Help_Initialize = Window_Help.prototype.initialize;
Window_Help.prototype.initialize = function(numLines) {
    SWDA_Help.Window_Help_Initialize.call(this, numLines);
    this._footnote = new Sprite(new Bitmap(this.width, this.height));
    this.addChild(this._footnote);
    
    this._footnote.bitmap.fontSize = 20;
    this._footnote.bitmap.textColor = '#ffffff';
    this._footnote.bitmap.opacity = 128;
    this._footnote.bitmap.outlineWidth = 0.5;
    this.refreshFootnote();
};


SWDA_Help.Window_Help_setText = Window_Help.prototype.setText;
Window_Help.prototype.setText = function(text) {
    SWDA_Help.Window_Help_setText.call(this, text);
    this.refreshFootnote();
};

Window_Help.prototype.setExt = function(ext) {
    if (this._ext !== ext) {
        this._ext = ext;
        this.refresh();
    }
};

// 更新文字提示内容
Window_Help.prototype.refreshFootnote = function(){
    let text = "";
    const item = this._item;
    const padding = 12;
    const fontSize = this._footnote.bitmap.fontSize;
    const align = 'right';
    this._footnote.bitmap.clear();
    if (item && CP.ItemInputManager.isNeedChangeText()){
        if(CP.ItemInputManager.hasSecondaryText(item) && (item.description.trim() === "" || $gameSystem.showSecondaryData())){
            text = "按切换键/点击查看详细说明";
        }else{
            text = "按切换键/点击查看功能说明";
        }
        this._footnote.bitmap.drawText(text, 0, this.height - padding - fontSize, this.width - padding, fontSize, align);
    }
}

// 提前获取item，用于判断是否需要刷新右下角文字提示
SWDA_Help.Window_Help_setItem = Window_Help.prototype.setItem;
Window_Help.prototype.setItem = function(item) {
    // 对于可使用装备，战斗中显示物品数据的二级说明
    if($gameParty.inBattle()){
        if(CP.UseEquipManager.isEquipUsable(item))
                item = CP.UseEquipManager.getRealUseItem(item);
    }else if(!!this._ext){
        if(this._ext == '恢复' || this._ext == '攻击' || this._ext == '辅助'){
            if(CP.UseEquipManager.isEquipUsable(item))
                item = CP.UseEquipManager.getRealUseItem(item);
        }
    }
    this._item = item;  // 提前获取item
	SWDA_Help.Window_Help_setItem.call(this, item);
};


/*

//-----------------------------------------------------------------------------
// Window_Help
//
// The window for displaying the description of the selected item.

function Window_Help() {
    this.initialize.apply(this, arguments);
}

Window_Help.prototype = Object.create(Window_Base.prototype);
Window_Help.prototype.constructor = Window_Help;

Window_Help.prototype.initialize = function(numLines) {
    var width = Graphics.boxWidth;
    var height = this.fittingHeight(numLines || 2);
    Window_Base.prototype.initialize.call(this, 0, 0, width, height);
    this._text = '';
};

Window_Help.prototype.setText = function(text) {
    if (this._text !== text) {
        this._text = text;
        this.refresh();
    }
};

Window_Help.prototype.clear = function() {
    this.setText('');
};

Window_Help.prototype.setItem = function(item) {
    this.setText(item ? item.description : '');
};

Window_Help.prototype.refresh = function() {
    this.contents.clear();
    this.drawTextEx(this._text, this.textPadding(), 0);
};


*/